{extend name="layout:base" /}{block name="content"}
<?php
$global=isSupperManagerForSession();
?>
<style>
.table th{text-align:center;}
.tip{position:absolute;background:#9FC;border-color:#F60;z-index:9999;filter:alpha(opacity=80);-moz-opacity:0.8;-khtml-opacity: 0.8;opacity: 0.8;}
.hidden-detail{display:none;}
.mypointer{width:95%;overflow:hidden;height:25px;line-height:25px;cursor: pointer;}

</style>

<link rel="stylesheet" type="text/css" href="/static/admin/css/style.css" />
<script src="/static/mimi/js/confirm/js/jquery-1.9.1.js"></script>

<link rel="stylesheet" href="/static/mimi/css/animate.min.css" type="text/css" />
<link rel="stylesheet" href="/static/mimi/css/font-awesome.min.css" type="text/css" />

<link rel="stylesheet" href="/static/treeselect/assets/layui/css/layui.css">
<script src="/static/treeselect/assets/layui/layui.js"></script>
<script src="/static/treeselect/module/common.js"></script>
<style>
    .ztree {
        margin: 0;
        padding: 0px;
        color: #333;
    }
    .layui-input {
        height: 28px;
        line-height: 26px;
        border: 0px;

    }
    .layui-input-block {
        margin-left: 10px;
        min-height: 24px;
    }
    .layui-form-item{
        width:200px;
        display: inline-block;
        height:30px;
        line-height: 28px;
        border: 1px #139667 solid;
    }
    #mCSB_3_container{
        min-height: 500px;

    }
    .layui-treeSelect .ztree li span.button{
        float: left;
    }
</style>
   
<section class="topBanners">
   <div class="icon"></div>
   <div class="topBannersNav">
   		<span data-url="/admin/hosparticle/lists" onclick="ContentLoadGo('/admin/hosparticle/lists')">文章管理</span>
   </div>
</section>
   
<section id="serach_section" style="margin-top:10px;margin-left:auto;margin-right:auto;">
      <select name="ser_key" id="ser_key" class="select" >
       <option value="name" <?php if($request['ser_key']=="name"){echo 'selected';} ?>>文章名称</option>
      </select>
      <input type="text" class="textbox" name="ser_val" id="ser_val" value="<?php echo $request['ser_val']; ?>" placeholder=""/>
      <input type="hidden" name="ser_pid" id="ser_pid" value="<?php echo $request['ser_pid']; ?>" />

        <div class="layui-form-item">
            <div class="layui-input-block">
                <input type="text" id="tree2" lay-filter="tree2" class="layui-input">
            </div>
        </div>

    <select id="ser_bigtype" class="ser_stats select" name="ser_bigtype">
        <option value="">--类型--</option>
        <?php
        foreach($bigTypeLists as $k=>$v){
        ?>
        <option value="<?php echo $v['id']; ?>" <?php if($request['ser_bigtype']==$v['id']){echo 'selected';} ?> ><?php echo $v['name'] ?></option>
        <?php
        }
        ?>
    </select>

      <select id="ser_stats" class="ser_stats select" name="ser_stats">
          <option value="">--状态--</option>
          <option value="0" <?php if($request['ser_stats']=='0'){echo 'selected';} ?> >上架</option>
          <option value="1" <?php if($request['ser_stats']=='1'){echo 'selected';} ?> >下架</option>
      </select>
      <input type="button" value="搜索" class="group_btn research" id="resource" page="1" />
      	<?php
	    if( ( in_array(30200,$ruleLists) || $global==1) )
		{
    	?>
      <input power="30200" type="button" value="添加" class="group_btn add fr" />
      	<?php
      	}
      	?>
      <br style="clear:both;width:0px;height:0px;">
</section>
 
<table class="table" style="margin-top:10px;">
<tr>
<th style="width:50px;">ID</th>
<th style="width:200px;">文章名称</th>
    <th style="width:50px;">类型</th>
<th style="width:50px;">发布人</th>
<th style="width:50px;">状态</th>

<th style="width:60px;">操作</th>
</tr>
<?php 
foreach($lists['data'] as $key=>$val)
{
?>
<tr data-id="<?php echo $val['id']; ?>">
<td style="text-align:left;"><?php echo $val['id']; ?></td>
<td style="text-align:left;">
<div class="mypointer" data-toggle="tooltip"
data-placement="bottom" title="<?php echo $val['name']; ?>" style="text-align: left;"><?php echo $val['name']; ?></div>
</td>
    <td><?php echo $bigTypeLists[$val['bigtype']]['name'];?></td>
<td><?php echo $val['UserInfo']['nickname'];?></td>
<td><?php echo $val['statsMapper'];?></td>

<td style="text-align:right;">

<?php
if($val['is_allow_delete']==0)
{
if($val['stats']=='0')
{
?>
<input type="button" power="30300" value="下架" class="link_btn xia"/>	
<?php 
}else
{
?>
<input type="button" power="30300" value="上架" class="link_btn shang"/>
<?php
}
}
?>




<?php
if( ( in_array(30100,$ruleLists) || $global==1) )
{
?>
<!--<input type="button" power="30100" value="详情" class="link_btn info"/>-->
<?php
}
?>

<?php
if( ( in_array(30300,$ruleLists) || $global==1) )
{
?>
<input type="button" power="30300" value="修改" class="link_btn edit"/>
<?php
}
?>
<?php
if( ( in_array(30400,$ruleLists) || $global==1) )
{
if($val['is_allow_delete']==0)
{
?>
<input type="button" power="30400" value="删除" class="link_btn del"/>
<?php
}
}
?>
</td>
</tr>

<?php
}
?>
</table>
{include file="../application/admin/view/layout/page_tpl_new.html" /}
<script type="text/javascript">
    layui.use(['treeSelect','form'], function () {
        var treeSelect= layui.treeSelect;
        treeSelect.render({
            // 选择器
            elem: '#tree2',
            // 数据
            data: '/admin/hosparticletype/ajaxData?check_id=<?php echo $request["ser_pid"] ?>',
            // 异步加载方式：get/post，默认get
            type: 'get',
            async: false,
            // 占位符
            placeholder: '',
            // 是否开启搜索功能：true/false，默认false
            search: true,
            // 点击回调
            click: function(d){
                console.log("===================");
                console.log(d.current.id);
                $("#ser_pid").val(d.current.id);
                console.log("===================");
            },
            // 加载完成后的回调函数
            success: function (d) {
                //选中节点
               treeSelect.checkNode('tree2',$("#ser_pid").val());
            }
        });

    });
function myResearch(){
    var url="/admin/hosparticle/lists";
    var ser_key =$("#ser_key").val();
    var ser_val =$("#ser_val").val()
    var ser_stats =$("#ser_stats").val();
    var ser_pid =$("#ser_pid").val();
    var ser_bigtype =$("#ser_bigtype").val();
    var page=$("#cpage").val();
    var param={
        ser_key:ser_key,
        ser_val:ser_val,
        ser_stats:ser_stats,
        ser_pid:ser_pid,
        ser_bigtype:ser_bigtype,
        page:page
    };
    ContentLoadGo(url,param);
}

$(function(){
 //设置搜索栏
 $(".research").unbind().bind("click",function(){
    var page =$(this).attr("page");
    $("#cpage").val(page);
    myResearch();
 });
 //上架
$(".shang").unbind().bind("click",function(){
   var that =this;
   var url="/admin/hosparticle/shangData";
   var id=$(that).parent().parent().attr('data-id');
   var param={
           id:id
   };
   cofirmsss_tishi(1,'您确定要执行该操作吗？',function(id){

       AjaxRequest(url,param,function(data){
           if(data.err==0)
           {
               SuccessTiShi("操作成功");

               $(that).parent().parent().remove();
               myResearch();
           }
           else
           {
               ErrTiShi(data.msg);
           }
       });

   });
});
//下架
$(".xia").unbind().bind("click",function(){
   var that =this;
   var url="/admin/hosparticle/xiaData";
   var id=$(that).parent().parent().attr('data-id');
   var param={
           id:id
   };
   cofirmsss_tishi(1,'您确定要执行该操作吗？',function(id){

       AjaxRequest(url,param,function(data){
           if(data.err==0)
           {
               SuccessTiShi("操作成功");

               $(that).parent().parent().remove();
               myResearch();
           }
           else
           {
               ErrTiShi(data.msg);
           }
       });

   });
});

//删除
$(".del").unbind().bind("click",function(){
   var that =this;
   var url="/admin/hosparticle/delData";
   var id=$(that).parent().parent().attr('data-id');
   var param={
           id:id
   };
   cofirmsss_tishi(1,'您确定要删除吗?',function(id){

       AjaxRequest(url,param,function(data){
           if(data.err==0)
           {
               SuccessTiShi("操作成功");

               $(that).parent().parent().remove();
               myResearch();
           }
           else
           {
               ErrTiShi("操作失败");
           }
       });

   });
});
//编辑
$(".edit").unbind().bind("click",function(){
   var that =this;
   var url="/admin/hosparticle/editData";
   var id=$(that).parent().parent().attr('data-id');
   var param={
           id:id
   };
   ContentLoadGo(url,param);

});
//详情
$(".info").unbind().bind("click",function(){
   var that =this;
   var url="/admin/hosparticle/infoData";
   var id=$(that).parent().parent().attr('data-id');
   var param={
           id:id
   };
   ContentLoadGo(url,param);

});

//详情
    $(".saleList").unbind().bind("click",function(){
        var that =this;
        var url="/admin/hosparticle/saleLists";
        var id=$(that).parent().parent().attr('data-id');
        var param={
            class_id:id
        };
        ContentLoadGo(url,param);

    });


        	   
//导航
$(".topBannerItem").unbind().bind("click",function(){
   var attArr = $(this).attr();
   goToSelfLink(attArr);

});
//添加
$(".add").unbind().bind("click",function(){
   var that =this;
   var url="/admin/hosparticle/addData";
   var param={};
   ContentLoadGo(url,param);
     //弹出：确认按钮
});
        	   
//全选
$("#all").unbind().bind("click",function(){
    if(this.checked){
        $(".checkBoxInput").attr("checked", true);
        $(".checkBoxInput").prop("checked", true);
    }else{
        $(".checkBoxInput").attr("checked", false);
        $(".checkBoxInput").prop("checked", false);
    }
    var se=getAllSelectItem();
});

});
</script>

{/block}
   